<script language="javascript">
function createXMLHttp()
    {
        var xmlHttp =false;
        try{
          xmlHttp = new XMLHttpRequest();
        }
        catch(e)
        {
          xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
        }
        if (!xmlHttp)
        {
          alert("Loi ...");
        }
        else
        {
          return xmlHttp;
        
        }
    
    }
    
        
var xmlHttp = new createXMLHttp();
function comboChange(v)
{
  var url = "include/get-khtt.php?q="+v;
//alert(url);
 if (xmlHttp.readyState==4 || xmlHttp.readyState==0)
      {
        xmlHttp.open("GET", url, true);
        xmlHttp.onreadystatechange=Func;
        xmlHttp.send(null);
      }
}
function Func()
{
    //alert("Here xmlHttp.readyState="+xmlHttp.readyState);
   		
        if (xmlHttp.readyState==4)
        {
            if (xmlHttp.status==200)
            {
               // alert("Ket qua="+xmlHttp.responseText);
				var s='<table width="560" border="0" cellspacing="0" cellpadding="0" style="border-left:1px solid #333;border-right:1px solid #333;border-bottom:1px solid #333">';
				s += xmlHttp.responseText;
				s +="</table>";
				document.getElementById("khtt").innerHTML=s;
                //var oXML = xmlHttp.responseXML;
                //var oXML =oXML.documentElement;
       		}
			else
			 alert("Coloi tu server.");
		}
		
}

</script>
<?php
	include("connect.php");
	function print_option($sql)
	{
		$kq=mysql_query($sql);
		while ($r=mysql_fetch_array($kq))
			echo "<option value='$r[0]'> $r[0] </option>";
	}
?>

<table width="560" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #333">
  <tr>
    <td class="tieude" align="center" height="40">DANH SÁCH KHÁCH HÀNG THÂN THIẾT</td>
  </tr>
  <tr>  	
    <td align="center" height="30">
     <select name="thanhpho" style="width:240px" onchange="comboChange(this.value);">
        <option value="chon" selected="selected">--------- Chọn Thành Phố ---------</option>
    <?php print_option("select DISTINCT thanhpho from khachhangthanthiet"); ?>
        </select>
    </td>
  </tr>
</table>
<div id="khtt">
<?php include "include/khtt-list.php"; ?>
</div>